package dataStorage;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.el.ELResolver;
import javax.faces.context.FacesContext;

public class DBData {

	public static String DBname ="WebProjectDB";
	public static String DBusername ="root";
	public static String DBpassword ="kikinda1";
	public static String DBurl = new String("jdbc:mysql://localhost:3306/" + DBname);
	
	
	public static Connection getConnection() throws SQLException, ClassNotFoundException{
		Class.forName("com.mysql.jdbc.Driver");
		return DriverManager.getConnection(DBurl, "root","kikinda1");
	}
	
	public static Object getSessionBean(String beanName) {
		  FacesContext fcontext = FacesContext.getCurrentInstance();
		  ELResolver resolver = fcontext.getApplication().getELResolver();
		  return resolver.getValue(fcontext.getELContext(), null, beanName);
	}

}
